dism resource: add sourcePath parameter to allow for offline feature installs#1561
dism resource: add sourcePath parameter to allow for offline feature installs#1561Alex-shearing wants to merge 18 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for specifying DISM sourcePaths when enabling optional features/capabilities, enabling offline/alternate source installation scenarios.
Changes:
- Extend OptionalFeatureList/FeatureOnDemandList inputs/outputs with an optional
sourcePathsarray. - Validate
sourcePathsin set handlers and pass them into DISM calls. - Update resource schemas and docs to document the new property and examples.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| resources/dism_dsc/src/optional_feature/types.rs | Adds source_paths field to OptionalFeatureList model. |
| resources/dism_dsc/src/optional_feature/set.rs | Validates/passes source_paths into enable operation; includes in output. |
| resources/dism_dsc/src/optional_feature/get.rs | Includes source_paths in Get output payload. |
| resources/dism_dsc/src/optional_feature/export.rs | Sets source_paths: None in Export output. |
| resources/dism_dsc/src/feature_on_demand/types.rs | Adds source_paths field to FeatureOnDemandList model. |
| resources/dism_dsc/src/feature_on_demand/set.rs | Validates/passes source_paths into add capability; includes in output. |
| resources/dism_dsc/src/feature_on_demand/get.rs | Includes source_paths in Get output payload. |
| resources/dism_dsc/src/feature_on_demand/export.rs | Sets source_paths: None in Export output. |
| resources/dism_dsc/src/dism.rs | Extends DISM FFI calls to pass SourcePaths/SourcePathCount. |
| resources/dism_dsc/optionalfeature.dsc.resource.json | Adds sourcePaths to resource schema. |
| resources/dism_dsc/featureondemand.dsc.resource.json | Adds sourcePaths to resource schema. |
| resources/dism_dsc/locales/en-us.toml | Adds localized error string for invalid source path. |
| docs/reference/resources/Microsoft/Windows/OptionalFeatureList/index.md | Documents sourcePaths and updates links. |
| docs/reference/resources/Microsoft/Windows/OptionalFeatureList/examples/enable-disable-optional-features.md | Adds example using offline source. |
| docs/reference/resources/Microsoft/Windows/FeatureOnDemandList/index.md | Documents sourcePaths and adds link. |
| docs/reference/resources/Microsoft/Windows/FeatureOnDemandList/examples/install-remove-feature-on-demand.md | Adds example using offline source. |
SteveL-MSFT
left a comment
There was a problem hiding this comment.
This looks fine to me, @Alex-shearing you tested this locally? @michaeltlombardi can you do a docs pass on this? Thanks.
Yes, tested successfully on my local. My testing included multiple full removals and re-installs of the features, while disconnected from the internet (with a local SxS file) |
|
@Alex-shearing can you resolve the merge conflict? |
michaeltlombardi
left a comment
There was a problem hiding this comment.
Requesting some changes mostly centered on updating the JSON Schema to more correctly represent the property (write-only, minimum count, uniqueness).
| - **Instance properties:** <a id="instance-properties"></a> The following properties are optional. | ||
| They define the desired state for an instance of the resource. | ||
|
|
||
| - [sourcePaths](#sourcePaths) - The location of the source files to use for installation if | ||
| necessary. |
There was a problem hiding this comment.
I think this is more correctly a write-only property, given that it only affects how the resource behaves during a Set operation.
Instance properties typically represent actual properties of the underlying resource (like the name of the feature and whether it exists) where write-only properties affect how the resource behaves and read-only properties are metadata about the resource that the user can't directly and idempotently manage (like the last write time for a file or the author for a software package).
| - **Instance properties:** <a id="instance-properties"></a> The following properties are optional. | |
| They define the desired state for an instance of the resource. | |
| - [sourcePaths](#sourcePaths) - The location of the source files to use for installation if | |
| necessary. | |
| - **Write-only properties:** <a id="write-only-properties"></a> The resource accepts the following | |
| properties that affect its behavior but can't be retrieved for the actual state of an instance. | |
| For more information about read-only properties, see the "Write-only resource properties" section | |
| in [DSC resource properties][aa]. | |
| - [sourcePaths](#sourcePaths) - The location of the source files to use for installation if | |
| necessary. |
| <details><summary>Expand for <code>sourcePaths</code> property metadata</summary> | ||
|
|
||
| ```yaml | ||
| Type : array | ||
| IsRequired : false | ||
| IsKey : false | ||
| IsReadOnly : false | ||
| ``` | ||
|
|
||
| </details> | ||
|
|
||
| Supplied at the top level of the **Set** operation, indicates the location of the source files to | ||
| use for installation if necessary. The DISM API will search these paths if the feature files are | ||
| not available in the local feature store. See the [feature on demand repository documentation][08] | ||
| for more information on valid sources. | ||
|
|
||
| This property is optional and will be omitted from the response if no value is provided. |
There was a problem hiding this comment.
| <details><summary>Expand for <code>sourcePaths</code> property metadata</summary> | |
| ```yaml | |
| Type : array | |
| IsRequired : false | |
| IsKey : false | |
| IsReadOnly : false | |
| ``` | |
| </details> | |
| Supplied at the top level of the **Set** operation, indicates the location of the source files to | |
| use for installation if necessary. The DISM API will search these paths if the feature files are | |
| not available in the local feature store. See the [feature on demand repository documentation][08] | |
| for more information on valid sources. | |
| This property is optional and will be omitted from the response if no value is provided. | |
| <details><summary>Expand for <code>sourcePaths</code> property metadata</summary> | |
| ```yaml | |
| Type : array | |
| ItemsType : string | |
| ItemsMinimumCount : 1 | |
| ItemsMustBeUnique : true | |
| IsRequired : false | |
| IsKey : false | |
| IsReadOnly : false | |
| IsWriteOnly : true | |
| ``` | |
| </details> | |
| Indicates where the resource should look for source files to install a feature when the feature | |
| files aren't available in the local feature store for offline systems. Specify this property as an | |
| array of one or more unique strings where each string represents the path to a source file to use. | |
| This property affects how the resource behaves during **Set** operations. It has no affect for any | |
| other resource operations. For more information about valid sources for the DISM API, see the | |
| [`/Enable-Feature` reference for the `dism` command][08]. |
| "sourcePaths": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| }, |
There was a problem hiding this comment.
| "sourcePaths": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| }, | |
| "sourcePaths": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| }, | |
| "minItems": 1, | |
| "uniqueItems": true | |
| }, |
| - **Instance properties:** <a id="instance-properties"></a> The following properties are optional. | ||
| They define the desired state for an instance of the resource. |
There was a problem hiding this comment.
| - **Instance properties:** <a id="instance-properties"></a> The following properties are optional. | |
| They define the desired state for an instance of the resource. | |
| - **Write-only properties:** <a id="write-only-properties"></a> The resource accepts the following | |
| properties that affect its behavior but can't be retrieved for the actual state of an instance. | |
| For more information about read-only properties, see the "Write-only resource properties" section | |
| in [DSC resource properties][aa]. |
| [06]: ../FeatureOnDemandList/index.md | ||
| [07]: /windows-server/administration/windows-commands/dism/dism-operating-system-package-servicing-command-line-options | ||
| [07]: /windows-hardware/manufacture/desktop/deployment-image-servicing-and-management--dism--command-line-options | ||
| [08]: /windows-hardware/manufacture/desktop/dism-operating-system-package-servicing-command-line-options#enable-feature No newline at end of file |
There was a problem hiding this comment.
| [08]: /windows-hardware/manufacture/desktop/dism-operating-system-package-servicing-command-line-options#enable-feature | |
| [08]: /windows-hardware/manufacture/desktop/dism-operating-system-package-servicing-command-line-options#enable-feature | |
| [aa]: ../../../../../concepts/resources/properties.md#write-only-resource-properties |
| [05]: ../../../../../concepts/resources/properties.md#read-only-resource-properties | ||
| [06]: ../OptionalFeatureList/index.md | ||
| [07]: /windows-hardware/manufacture/desktop/features-on-demand-v2--capabilities | ||
| [08]: /windows-hardware/manufacture/desktop/features-on-demand-v2--capabilities?view=windows-11#fod-repositories No newline at end of file |
There was a problem hiding this comment.
| [08]: /windows-hardware/manufacture/desktop/features-on-demand-v2--capabilities?view=windows-11#fod-repositories | |
| [08]: /windows-hardware/manufacture/desktop/features-on-demand-v2--capabilities?view=windows-11#fod-repositories | |
| [aa]: ../../../../../concepts/resources/properties.md#write-only-resource-properties |
| <details><summary>Expand for <code>sourcePaths</code> property metadata</summary> | ||
|
|
||
| ```yaml | ||
| Type : array | ||
| IsRequired : false | ||
| IsKey : false | ||
| IsReadOnly : false | ||
| ``` | ||
|
|
||
| </details> | ||
|
|
||
| Supplied at the top level of the **Set** operation, indicates the location of the source files to | ||
| use for installation if necessary. The DISM API will search these paths if the feature files are | ||
| not available in the local feature store. See the [DISM enable feature documentation][08] for more | ||
| information on valid sources. | ||
|
|
||
| This property is optional and will be omitted from the response if no value is provided. |
There was a problem hiding this comment.
| <details><summary>Expand for <code>sourcePaths</code> property metadata</summary> | |
| ```yaml | |
| Type : array | |
| IsRequired : false | |
| IsKey : false | |
| IsReadOnly : false | |
| ``` | |
| </details> | |
| Supplied at the top level of the **Set** operation, indicates the location of the source files to | |
| use for installation if necessary. The DISM API will search these paths if the feature files are | |
| not available in the local feature store. See the [DISM enable feature documentation][08] for more | |
| information on valid sources. | |
| This property is optional and will be omitted from the response if no value is provided. | |
| <details><summary>Expand for <code>sourcePaths</code> property metadata</summary> | |
| ```yaml | |
| Type : array | |
| ItemsType : string | |
| ItemsMinimumCount : 1 | |
| ItemsMustBeUnique : true | |
| IsRequired : false | |
| IsKey : false | |
| IsReadOnly : false | |
| IsWriteOnly : true | |
| ``` | |
| </details> | |
| Indicates where the resource should look for source files to install a feature when the feature | |
| files aren't available in the local feature store for offline systems. Specify this property as an | |
| array of one or more unique strings where each string represents the path to a source file to use. | |
| This property affects how the resource behaves during **Set** operations. It has no affect for any | |
| other resource operations. For more information about valid sources for the DISM API, see the | |
| [`/Enable-Feature` reference for the `dism` command][08]. |
| "sourcePaths": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| }, |
There was a problem hiding this comment.
| "sourcePaths": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| } | |
| }, | |
| "sourcePaths": { | |
| "type": "array", | |
| "items": { | |
| "type": "string" | |
| }, | |
| "minItems": 1, | |
| "uniqueItems": true | |
| }, |
| "sourcePaths": { | ||
| "type": "array", | ||
| "title": "Source paths", | ||
| "description": "An array of paths to feature files if the files are not available in the local feature store. This is an optional property for set operations and is ignored for get operations.", | ||
| "items": { | ||
| "type": "string" | ||
| } |
There was a problem hiding this comment.
| "sourcePaths": { | |
| "type": "array", | |
| "title": "Source paths", | |
| "description": "An array of paths to feature files if the files are not available in the local feature store. This is an optional property for set operations and is ignored for get operations.", | |
| "items": { | |
| "type": "string" | |
| } | |
| "sourcePaths": { | |
| "type": "array", | |
| "writeOnly": true, | |
| "title": "Source paths", | |
| "description": "An array of paths to feature files if the files are not available in the local feature store. This is an optional property for set operations and is ignored for get operations.", | |
| "items": { | |
| "type": "string" | |
| }, | |
| "minItems": 1, | |
| "uniqueItems": true |
| "sourcePaths": { | ||
| "type": "array", | ||
| "title": "Source paths", | ||
| "description": "An array of paths to feature files if the files are not available in the local feature store. This is an optional property for set operations and is ignored for get operations.", | ||
| "items": { | ||
| "type": "string" | ||
| } |
There was a problem hiding this comment.
| "sourcePaths": { | |
| "type": "array", | |
| "title": "Source paths", | |
| "description": "An array of paths to feature files if the files are not available in the local feature store. This is an optional property for set operations and is ignored for get operations.", | |
| "items": { | |
| "type": "string" | |
| } | |
| "sourcePaths": { | |
| "type": "array", | |
| "writeOnly": true, | |
| "title": "Source paths", | |
| "description": "An array of paths to feature files if the files are not available in the local feature store. This is an optional property for set operations and is ignored for get operations.", | |
| "items": { | |
| "type": "string" | |
| }, | |
| "minItems": 1, | |
| "uniqueItems": true |
To allow Windows optional features and feature on demand installs on Windows computers without internet access, the source paramter must be accessible to supply offline resources.
This is available as the 'Source' paramter in:
Install-WindowsFeaturePowerShell CmdLet: https://learn.microsoft.com/en-us/powershell/module/servermanager/install-windowsfeature?view=windowsserver2025-psEnable-WindowsOptionalFeaturePowerShell CmdLet: https://learn.microsoft.com/en-us/powershell/module/dism/enable-windowsoptionalfeature?view=windowsserver2025-psWindowsFeatureSetPowerShell DSC Resource: https://learn.microsoft.com/en-us/powershell/dsc/reference/resources/windows/windowsfeaturesetresource?view=dsc-1.1The changes include:
sourcePathproperty toMicrosoft.Windows/FeatureOnDemandListandMicrosoft.Windows/OptionalFeatureListschemassource_pathsparamter toenable_featureandadd_capabilityfunctions in dism.rs